﻿using System;
using System.Collections.Generic;
using System.Windows.Data;
using System.Linq;
using System.Text;

namespace VideoReflector.Converters
{
    /// <summary>
    /// Value Converter which returns a TimeSpan object corresponding to the number of seconds in the passed integer value
    /// </summary>
    [ValueConversion(typeof(int), typeof(TimeSpan))]
    public class IntSecondsToTimeSpanConverter : ConverterWithMarkupExtension, IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return new TimeSpan(0, 0, System.Convert.ToInt32(value));
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return ((TimeSpan)value).TotalSeconds;
        }
    }
}
